package com.htfyun.roobofactory.rooboUtils;

import android.content.Context;

import com.iflytek.cloud.util.ResourceUtil;

/**
 * Created by yuanshuqi on 2017/2/22 10:20.
 * email:yuanshuqi@roo.bo
 */
public class RooboEngine {
    private static RooboEngine ourInstance = new RooboEngine();
    private Context mContext;
    private XunFeiWakeUpTranslator mTranslator;
    private RooboRecorder rooboRecorder;

    public static RooboEngine getInstance() {
        return ourInstance;
    }

    private RooboEngine() {
    }

    public void init(Context context) {
        this.mContext = context.getApplicationContext();
        rooboRecorder = new RooboRecorder(this);
        mTranslator = new XunFeiWakeUpTranslator(ResourceUtil.generateResourcePath(mContext,
                ResourceUtil.RESOURCE_TYPE.assets, "ivw/552cd878.jet"), mContext);
        mTranslator.init();
        rooboRecorder.startRecord();
    }

    public void produceData(byte[] data) {
        mTranslator.translateVoice(data);
    }

    public int getScore() {
        return mTranslator.getScore();
    }

    public void setScore(int score) {
        mTranslator.setScore(score);
    }

    public void setWakeupListener(XunFeiWakeUpTranslator.WakeupListener listener) {
        mTranslator.setWakeupListener(listener);
    }

    public void destroy() {
        rooboRecorder.destroyRecorder();

    }

    public void startRecord() {
        rooboRecorder.startRecord();
    }
}
